﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HyperPin_Database_Editor
{
    public partial class HPExitProgramSettings : HPSettingsPanel
    {
        static string iniExecutable = "Executable";
        static string iniParamers = "Parameters";
        static string iniWorkingDirectory = "Working_Directory";
        static string iniWinState = "WinState";

        public HPExitProgramSettings()
        {
            InitializeComponent();
        }

        public override void doLoadSettings()
        {
            textExecutable.Text = readSetting(iniExecutable, "");
            textParameters.Text = readSetting(iniParamers, "");
            textWorkingDirectory.Text = readSetting(iniWorkingDirectory, "");
            comboWinState.Text = readSetting(iniWinState, "Normal");
        }

        public override void doSaveSettings()
        {
            writeSetting(iniExecutable, textExecutable.Text);
            writeSetting(iniParamers, textParameters.Text);
            writeSetting(iniWorkingDirectory, textWorkingDirectory.Text);
            writeSetting(iniWinState, comboWinState.Text);
        }

        private void buttonBrowseExecutable_Click(object sender, EventArgs e)
        {
            openFileDialogExecutable.FileName = "*.exe";
            openFileDialogExecutable.Filter = "Executable Files (*.exe)|*.exe";
            openFileDialogExecutable.FilterIndex = 1;
            DialogResult result = openFileDialogExecutable.ShowDialog();
            if (result == DialogResult.OK)
            {
                textExecutable.Text = openFileDialogExecutable.FileName;
            }
        }

        private void buttonBrowseWorkingDirectory_Click_1(object sender, EventArgs e)
        {
            folderBrowserDialogWorkingDirectory.Description = "Seclect working directory for the startup program.";
            DialogResult result = folderBrowserDialogWorkingDirectory.ShowDialog();
            if (result == DialogResult.OK)
            {
                textWorkingDirectory.Text = folderBrowserDialogWorkingDirectory.SelectedPath;
            }
        }
    }
}
